import logging

from redis import StrictRedis


class Config(object):
    """工程配置信息"""
    SECRET_KEY = 'V+S2ML4GAOM4ucj5Yzac8AwfFg10qwYCNiEOIiY5DTiqXVJBhyH41Q53udaVzvr5'
    DEBUG = True

    # 数据库的配置信息
    SQLALCHEMY_DATABASE_URI = "mysql://root:mysql@127.0.0.1:3306/information27"
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True


    # redis配置
    REDIS_HOST = '127.0.0.1'
    REDIS_PORT = 6379

    # flask_session的配置信息
    SESSION_TYPE = 'redis' # 指定session保存到redis中
    SESSION_USE_SIGNER = True # 让cookie中的session_id被加密签名处理
    SESSION_REDIS = StrictRedis(host=REDIS_HOST, port=REDIS_PORT) # 使用redis的实例
    PERMANENT_SESSION_LIFETIME = 86400 # session的有效期,单位秒

    # 设置日志等级
    LOG_LEVEL = logging.DEBUG


class DevelopmentConfig(Config):
    DEBUG = True


class ProductionConfig(Config):
    DEBUG = False
    LOG_LEVEL = logging.WARNING


class TestingConfig(Config):
    DEBUG = True
    TESTING = True


config = {
    'development':DevelopmentConfig,
    'production':ProductionConfig,
    'testing':TestingConfig
}
